package com.gitee.wsl.compose.chart.sleepgraph.bean

import com.gitee.wsl.time.between
import kotlinx.datetime.LocalDateTime
import kotlin.time.Duration

data class SleepDayData( // 每日睡眠数据
    val startDate: LocalDateTime,
    val sleepPeriods: List<SleepPeriod>,
    val sleepScore: Int,
) {
    val firstSleepStart: LocalDateTime by lazy {
        sleepPeriods.minByOrNull(SleepPeriod::startTime)!!.startTime
    }
    val lastSleepEnd: LocalDateTime by lazy {
        sleepPeriods.maxByOrNull(SleepPeriod::startTime)!!.endTime
    }
    val totalTimeInBed: Duration by lazy {
        Duration.between(firstSleepStart, lastSleepEnd)
    }
}
